package controller;

import model.MySql;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 主页
 * Created by yvdedu.com on 2016/9/28.
 */
@WebServlet(urlPatterns = "/www/main")
public class main extends HttpServlet{
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        MySql mySql=new MySql();
        if (req.getSession().getAttribute("user")!=null){
            req.setAttribute("userinfo",mySql.getUserByName(String.valueOf(req.getSession().getAttribute("user"))));
        }
        req.setAttribute("hotbook",mySql.getBookByClick());
        req.setAttribute("showbook",mySql.getBookByRandom());
        req.getRequestDispatcher("xsw.jsp").forward(req,resp);
    }
}
